package com.tjec.project.msg.factory;
import com.tjec.project.msg.mobset.bean.DataObjectBean;
import com.tjec.project.msg.tempuri.MobsetApi;
import com.tjec.project.msg.tempuri.MobsetApiLocator;
import com.tjec.project.msg.tempuri.MobsetApiSoap;
import com.tjec.project.msg.tempuri.MobsetApiSoapStub;

import java.net.URL;
import javax.xml.rpc.ServiceException;

/**
 * @author villwang
 * @date 2020/07/09
 **/
public class DataObjectFactory {
    private static DataObjectBean mobsetBean = null;
    private static MobsetApiSoap mobsetApiSub = null;
    private static MobsetApi mobsetApi = null;
    private static MobsetApiLocator mobsetLocator = null;

    private DataObjectFactory() {
    }

    public static DataObjectBean getInstance() {
        if (mobsetBean == null) {
            mobsetBean = new DataObjectBean();
        }

        return mobsetBean;
    }

    public static MobsetApiSoap getMobsetApi() {
        if (mobsetApi == null) {
            try {
                mobsetApi = new MobsetApiLocator();
                mobsetApiSub = (MobsetApiSoapStub)mobsetApi.getMobsetApiSoap();
            } catch (ServiceException var1) {
                var1.printStackTrace();
            }
        }

        return mobsetApiSub;
    }

    public static MobsetApiSoap getMobsetApi(URL portAddress) {
        if (mobsetApi == null) {
            try {
                mobsetApi = new MobsetApiLocator();
                mobsetApiSub = (MobsetApiSoapStub)mobsetApi.getMobsetApiSoap(portAddress);
            } catch (ServiceException var2) {
                var2.printStackTrace();
            }
        }

        return mobsetApiSub;
    }
}

